Add ActorMonitor for tracking actor lifecycle and overflow status#83
Conversation
ddrcode
left a comment
There was a problem hiding this comment.
Hi. Thanks again - good work, good tests. I left 3 comments in the code asking for minor changes. Please note that the main branch has changed since your PR, so make sure you rebase, before submitting the new change. Cheers.
| /// Called when a new actor is registered in the system. | ||
| /// | ||
| /// Fires once when the actor is spawned and added to the broker registry. | ||
| fn on_actor_registered(&self, actor_id: &ActorId) { |
There was a problem hiding this comment.
This is good and useful, but... it's not plugged anywhere in Maiko's code, so technically it's a dead code. It should be invoked in supervisor when monitoring enabled. That's the only supervisor change needed (unlike the original version of the PR). Alternatively you could catch in in broker.rs.
|
|
||
| /// Monitor that tracks actor lifecycle and overflow status. | ||
| pub struct ActorMonitor { | ||
| inner: Arc<Mutex<ActorMonitorInner>>, |
There was a problem hiding this comment.
Monitors run always as a single Tokio task - using Mutex adds unnecessary overhead, you could easily use Rc<RefCell<>> instead. Or - for numeric values - atomics.
See Tracer or Recorder for references.
|
|
||
| /// Status returned by `actor_status()`. | ||
| #[derive(Debug, Clone, PartialEq, Eq)] | ||
| pub enum ActorStatus { |
There was a problem hiding this comment.
Conflates lifecycle and overflow history - an actor that overflowed once reports as Overflowing forever - that might be misleading. Sorry if my comment in the previous review was confusing here. What would make more sense would be to have status indicitaing only whether an actor is alive or stopped, and then the overflow_count on top of it. Or - even simplier - is_alive() and overflow_count().
Don't worry about my review, I have merged the PR and applied the changes myself as i want to release new version shortly. All good. Thanks for the contribution!
* Add ActorMonitor for tracking actor lifecycle and overflow status (#83) Don't worry about my review, I have merged the PR and applied the changes myself as i want to release new version shortly. All good. Thanks for the contribution! * adjustments to proposed pr [#26] --------- Co-authored-by: Nikhil Patil <nikhil876706@gmail.com>
|
Merged with main in #86 |
This PR implements (#26). A lightweight actor lifecycle introspection mechanism using the existing monitoring layer, without requiring any changes to the supervisor. It enables runtime visibility into actor states such as active, stopped, or overflowing by passively observing lifecycle events. The monitor maintains an internal view of actors and their status, allowing runtime insights while keeping the implementation modular and fully decoupled.